package com.csproj.example.service.dto;


import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.Objects;

/**
 * A DTO for the Organization entity.
 */
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class OrganizationDTO implements Serializable {

    private String id;

    private Integer no;

    private String code;

    private String parentCode;

    @NotNull(message = "名称不能为空")
    @Size(max = 20,message = "名称长度最大为20！")
    private String name;

    @Min(value = 0,message = "类型最小为0！")
    private Integer type;

    private String createBy;

    private ZonedDateTime createDate;

    private String createName;

    public String getId() {
        return id;
    }

    public OrganizationDTO setId(String id) {
        this.id = id;
        return this;
    }

    public Integer getNo() {
        return no;
    }

    public OrganizationDTO setNo(Integer no) {
        this.no = no;
        return this;
    }

    public String getCode() {
        return code;
    }

    public OrganizationDTO setCode(String code) {
        this.code = code;
        return this;
    }

    public String getParentCode() {
        return parentCode;
    }

    public OrganizationDTO setParentCode(String parentCode) {
        this.parentCode = parentCode;
        return this;
    }

    public String getName() {
        return name;
    }

    public OrganizationDTO setName(String name) {
        this.name = name;
        return this;
    }

    public Integer getType() {
        return type;
    }

    public OrganizationDTO setType(Integer type) {
        this.type = type;
        return this;
    }

    public String getCreateBy() {
        return createBy;
    }

    public OrganizationDTO setCreateBy(String createBy) {
        this.createBy = createBy;
        return this;
    }

    public ZonedDateTime getCreateDate() {
        return createDate;
    }

    public OrganizationDTO setCreateDate(ZonedDateTime createDate) {
        this.createDate = createDate;
        return this;
    }

    public String getCreateName() {
        return createName;
    }

    public OrganizationDTO setCreateName(String createName) {
        this.createName = createName;
        return this;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        OrganizationDTO organizationDTO = (OrganizationDTO) o;
        if(organizationDTO.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), organizationDTO.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "OrganizationDTO{" +
            "id=" + getId() +
            ", no='" + getNo() + "'" +
            ", code='" + getCode() + "'" +
            ", parentCode='" + getParentCode() + "'" +
            ", name='" + getName() + "'" +
            ", type='" + getType() + "'" +
            ", createBy='" + getCreateBy() + "'" +
            ", createDate='" + getCreateDate() + "'" +
            ", createName='" + getCreateName() + "'" +
            "}";
    }
}
